<?php
    $xtpl_left  = new XTemplate("view/left.htm");
    $offset     = $_GET['p'];
    $limit      = 3;
    $offset     = (isset($offset) && ($offset > 0)) ? $offset : 0;
    
    $query  = "SELECT count(*) AS totalRecords FROM news";
    $re     = mysql_query($query);
    $rows   = mysql_fetch_assoc($re);
    $totalRecords   = $rows['totalRecords'];
    
    $pages  = pagging($totalRecords, $offset, $limit, 'index.php?page=news');    
    $sql    = "SELECT * FROM news ORDER BY id_n DESC LIMIT " . $offset . ", " . $limit . "";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)){
        $xtpl_left  -> assign('id', $row['id_n']);
        $xtpl_left  -> assign('title', $row['title']);
        $xtpl_left  -> insert_loop('LEFT.TITLES', array('LEFT'=>$row));
    }
    
    $xtpl_left  -> parse("LEFT");
    $left       = $xtpl_left -> text("LEFT");
?>